package Lesson14;

import java.util.Scanner;

public class AuctionDemo {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner (System.in);
		Auction auction = new Auction();
		do
		{
		System.out.println("Do you want the auction to start? y/n");
		if (sc.nextLine().equals("y"))
			auction.open();
		}
		while (!auction.isOpen);
		System.out.println("Insert the number of participants in the auction: ");
		auction.numberOfParticipants = sc.nextInt();
		System.out.println("Insert the number of cars in the auction: ");
		auction.numberOfCars =sc.nextInt();
		auction.participants = new Participant [auction.numberOfParticipants];
		auction.carsForSale = new Car [auction.numberOfCars];
		Participant[] arrParticipants = new Participant[auction.numberOfParticipants];
		
		// fill cars in auction
		for (int i=0; i<auction.carsForSale.length; i++)
		{
			auction.carsForSale[i] = new Car();
		}
		
		// for each car decide whether the current participant wants to buy it:
		for (int i = 0; i<auction.carsForSale.length; i++)
		{
			for (int j=0; j<arrParticipants.length; j++)
			{
				if (arrParticipants[j].carsRemaining>0)
					arrParticipants[j].toBuyOrNot();
				else
					continue;
			}
		}
	}

}
